import { VxeGridPropTypes } from '@/components/VxeTable';
import { Tag } from 'ant-design-vue';
import { EleTag } from 'ele-admin-pro';
import { h } from 'vue';

export default [
  {
    title: 'OpenId',
    field: 'openId'
  },
  {
    title: 'UnionId',
    field: 'unionId'
  },
  {
    title: '平台类型',
    field: 'platformType',
    slots: {
      default: ({ row }) => {
        const platformType = row.platformType;
        switch (platformType) {
          case 1:
            return h(EleTag, { color: 'blue' }, () => '微信公众号');
          case 2:
            return h(EleTag, { color: 'blue' }, () => '微信小程序');
          case 3:
            return h(EleTag, { color: 'blue' }, () => '支付宝小程序');
          case 4:
            return h(EleTag, { color: 'blue' }, () => '微信APP快捷登陆');
          case 5:
            return h(EleTag, { color: 'blue' }, () => 'QQ在APP中快捷登陆');
          case 6:
            return h(EleTag, { color: 'blue' }, () => '头条系小程序');
        }
      }
    }
  },
  {
    title: '昵称',
    field: 'nickName'
  },
  {
    title: '头像',
    field: 'avatar'
  },
  {
    title: '手机号码',
    field: 'mobile'
  },
  {
    title: '性别',
    field: 'sex',
    slots: {
      default: ({ row }) => {
        const sex = row.sex;
        const enable = ~~sex === 0;
        const color = enable ? 'green' : 'red';
        const text = enable ? '男' : '女';
        return h(Tag, { color: color }, () => text);
      }
    }
  },
  {
    title: '城市',
    field: 'city'
  },
  {
    title: '省',
    field: 'province'
  },

  {
    title: '国家',
    field: 'country'
  },
  {
    width: 140,
    title: '操作',
    align: 'center',
    slots: { default: 'action' },
    fixed: 'right'
  }
] as VxeGridPropTypes.Columns;
